package com.efast.cafe.portal.service.api.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.efast.cafe.framework.jdbc.JdbcDao;
import com.efast.cafe.framework.jdbc.bean.DBColumn;
import com.efast.cafe.framework.jdbc.bean.DBTable;
import com.efast.cafe.portal.service.api.IPortalJdbcService;
@Service
@Transactional
public class PortalJdbcServiceImp implements IPortalJdbcService {
	
	@Autowired
	@Qualifier("jdbcDao")
	private JdbcDao jdbcDao;

	@Override
	public List<String> getTables() {
		List<DBTable> tables = jdbcDao.getDataBaseTables();
		List<String> tableStr = new ArrayList<>();
		for (DBTable tb : tables) {
			tableStr.add(tb.getTableName());
		}
		return tableStr;
	}

	@Override
	public List<DBColumn> getColumns(String tableName) {
		if(tableName!=null){
			return jdbcDao.getColumns(tableName);
		}
		return null;
	}

}
